package com.payment.controller;

import com.alipay.api.AlipayApiException;
import com.payment.common.utils.ResultDataDto;
import com.payment.entity.vo.PayVO;
import com.payment.service.impl.AliServiceImpl;
import com.payment.service.impl.WxServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: Dgg
 * @Date: 2021/4/1 17:52
 * 支付控制层
 */
@RestController
public class PayController {
	@Autowired
	private AliServiceImpl aliService;
	@Autowired
	private WxServiceImpl wxService;
	/**
	 * 当面付：付款码支付(zfb,wx)
	 */
	@PostMapping("/paymentCode")
	public ResultDataDto paymentCode(@RequestBody PayVO payVO) throws AlipayApiException {
		String payType = payVO.getPayType();
		if ("1".equals(payType)) {
			System.out.println("进入aliservice");
			return aliService.AliPayCode(payVO);
		} else if ("2".equals(payType)) {
			System.out.println("进入weixinservice");
			return wxService.weixinPayCode(payVO);
		} else {
			return ResultDataDto.error("请选择正确的支付方式！");
		}
	}
	/**
	 * 当面付：扫码支付(zfb,wx)
	 */
	/**
	 * 网页支付(zfb,wx)
	 */
	/**
	 * 微信jsapi支付
	 */
	/**
	 * 小程序支付(wx)
	 */
	/**
	 * app 支付(zfb,wx)
	 */
	/**
	 * 刷脸支付(zfb,wx)
	 */
	/**
	 * 电脑网站支付
	 */
}
